SlideShare a Scribd company logo
Class No.31  Data Structures http://ecomputernotes.com
Timing with Optimization Theorem: A sequence of  m union  and  find  operations,  n  of which are  find  operations, can be performed on a disjoint-set forest with union by rank (weight or height) and path compression in worst case time proportional to ( m  ( n ))  ( n )is the inverse Ackermann’s function which grows extremely slowly. For all practical puposes,   ( n )  4. Union-find is essentially proportional to  m  for a sequence of  m  operations, linear in  m . http://ecomputernotes.com
Image Segmentation Inclusion criteria for pixels  use pixel intensity,  threshold of intensity, threshold for difference in intensity of neighbors,  texture (ie. a pattern of pixel intensities) http://ecomputernotes.com
Image Segmentation 0 1 2 3 4 0 0 0 0 4 4 1 2 0 4 4 0 2 4 2 2 4 4 3 4 4 0 4 4 4 0 2 2 4 0 http://ecomputernotes.com
Image Segmentation 0 1 2 3 4 0 0 0 0 4 4 1 2 0 4 4 0 2 4 2 2 4 4 3 4 4 0 4 4 4 0 2 2 4 0 0 1 2 3 4 0 0 0 0 1 1 1 0 0 1 1 0 2 1 0 0 1 1 3 1 1 0 1 1 4 0 0 0 1 0 Threshold=4 http://ecomputernotes.com
Image Segmentation 0 1 2 3 4 0 0 0 0 4 4 1 2 0 4 4 0 2 4 2 2 4 4 3 4 4 0 4 4 4 0 2 2 4 0 0 1 2 3 4 0 0 0 0 1 1 1 1 0 1 1 0 2 1 1 1 1 1 3 1 1 0 1 1 4 0 1 1 1 0 Threshold=2 http://ecomputernotes.com
Maze Generation http://ecomputernotes.com
Maze Generation A random maze generator can use union-find. Consider a 5x5 maze: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 http://ecomputernotes.com
Maze Generator  Initially, 25 cells, each isolated by walls from the others.  This corresponds to an equivalence relation -- two cells are equivalent if they can be reached from each other (walls been removed so there is a path from one to the other). http://ecomputernotes.com
Maze Generator To start, choose an entrance and an exit. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24   http://ecomputernotes.com
Maze Generator Randomly remove walls until the entrance and exit cells are in the same set.  Removing a wall is the same as doing a union operation.  Do not remove a randomly chosen wall if the cells it separates are already in the same set. http://ecomputernotes.com
MakeMaze MakeMaze(int size) { entrance = 0; exit = size-1; while (find(entrance) != find(exit)) { cell1 = randomly chosen cell cell2 = randomly chosen  adjacent  cell if (find(cell1) != find(cell2) { knock down wall between cells union(cell1, cell2) } } http://ecomputernotes.com
Maze Generator Cell 11, right wall chosen randomly 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24   http://ecomputernotes.com
Maze Generator Cell 11, right wall chosen randomly 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24   S_11 = { 11,12} http://ecomputernotes.com
Maze Generator Cell 6, bottom wall chosen randomly 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24   S_11 = { 11,12} http://ecomputernotes.com
Maze Generator Cell 6, bottom wall chosen randomly 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24   S_11 = { 11,12, 6} http://ecomputernotes.com
Maze Generator Cell 8, top wall chosen randomly 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24   S_11 = { 11,12, 6} http://ecomputernotes.com
Maze Generator Cell 8, top wall chosen randomly 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24   S_11 = { 11,12, 6} S_8 = { 8,3} http://ecomputernotes.com
Maze Generator Cell 14, top wall chosen randomly 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24   S_11 = { 11,12, 6} S_8 = { 8,3} http://ecomputernotes.com
Maze Generator Cell 14, top wall chosen randomly 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24   S_11 = { 11,12, 6} S_8 = { 8,3} S_14 = { 14,9} http://ecomputernotes.com
Maze Generator Cell 0, bottom wall chosen randomly 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24   S_11 = { 11,12, 6} S_8 = { 8,3} S_14 = { 14,9} http://ecomputernotes.com
Maze Generator Cell 0, bottom wall chosen randomly 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24   S_11 = { 11,12, 6} S_8 = { 8,3} S_14 = { 14,9} S_0 = { 0,5} http://ecomputernotes.com

More Related Content

PPT
Computer notes - Maze Generator
PPT
computer notes - Data Structures - 20
PPT
computer notes - Data Structures - 17
PPT
computer notes - Data Structures - 7
PPT
computer notes - Data Structures - 39
PPT
computer notes - Data Structures - 19
PPT
computer notes - Data Structures - 33
PPT
computer notes - Data Structures - 32
Computer notes - Maze Generator
computer notes - Data Structures - 20
computer notes - Data Structures - 17
computer notes - Data Structures - 7
computer notes - Data Structures - 39
computer notes - Data Structures - 19
computer notes - Data Structures - 33
computer notes - Data Structures - 32

Viewers also liked (20)

PPT
computer notes - Data Structures - 11
PPT
computer notes - Data Structures - 8
PPT
computer notes - Data Structures - 3
PPT
computer notes - Data Structures - 13
PPT
computer notes - Data Structures - 15
PPT
computer notes - Data Structures - 10
PPT
computer notes - Data Structures - 21
PPT
computer notes - Data Structures - 6
PPT
computer notes - Data Structures - 18
PDF
computer notes - Deleting a node
PPT
computer notes - Data Structures - 5
PPT
computer notes - Data Structures - 14
PPT
computer notes - Data Structures - 35
PPT
computer notes - Data Structures - 34
PPT
computer notes - Data Structures - 12
PPT
computer notes - Data Structures - 9
PPT
computer notes - Data Structures - 23
PPT
computer notes - Data Structures - 16
PPT
computer notes - Data Structures - 24
PPT
computer notes - Data Structures - 28
computer notes - Data Structures - 11
computer notes - Data Structures - 8
computer notes - Data Structures - 3
computer notes - Data Structures - 13
computer notes - Data Structures - 15
computer notes - Data Structures - 10
computer notes - Data Structures - 21
computer notes - Data Structures - 6
computer notes - Data Structures - 18
computer notes - Deleting a node
computer notes - Data Structures - 5
computer notes - Data Structures - 14
computer notes - Data Structures - 35
computer notes - Data Structures - 34
computer notes - Data Structures - 12
computer notes - Data Structures - 9
computer notes - Data Structures - 23
computer notes - Data Structures - 16
computer notes - Data Structures - 24
computer notes - Data Structures - 28
Ad

Similar to computer notes - Data Structures - 31 (20)

PDF
Find the shortest route through a maze using linking and linked list.pdf
PDF
Maze solving app listing
PPTX
Rat_in_a_maze((Dynamic programming-tabulation))
PDF
Fun with Mazes - sitNL 2015
DOCX
1) IntroductionThis practical work consists of developing
DOCX
1) IntroductionThis practical work consists of developing
PPTX
Rat_in_Maze(Dynamic programming-tabulation)
PDF
Skiena algorithm 2007 lecture18 application of dynamic programming
PPTX
Rat_in_a_maze((Dynamic programming-tabulation))
PPTX
Maze Problem Presentation
PDF
Bx24499504
PDF
Sienna 10 dynamic
PDF
Fun with Mazes
PPT
Chap08alg
PPT
Chap08alg
PPTX
Cellular automata
PDF
A Comprehensive and Comparative Study Of Maze-Solving Techniques by Implement...
PDF
E017142429
Find the shortest route through a maze using linking and linked list.pdf
Maze solving app listing
Rat_in_a_maze((Dynamic programming-tabulation))
Fun with Mazes - sitNL 2015
1) IntroductionThis practical work consists of developing
1) IntroductionThis practical work consists of developing
Rat_in_Maze(Dynamic programming-tabulation)
Skiena algorithm 2007 lecture18 application of dynamic programming
Rat_in_a_maze((Dynamic programming-tabulation))
Maze Problem Presentation
Bx24499504
Sienna 10 dynamic
Fun with Mazes
Chap08alg
Chap08alg
Cellular automata
A Comprehensive and Comparative Study Of Maze-Solving Techniques by Implement...
E017142429
Ad

More from ecomputernotes (18)

PPT
computer notes - Data Structures - 30
DOC
Computer notes - Including Constraints
DOC
Computer notes - Date time Functions
DOC
Computer notes - Subqueries
DOC
Computer notes - Other Database Objects
PPT
computer notes - Data Structures - 4
DOC
Computer notes - Advanced Subqueries
DOC
Computer notes - Aggregating Data Using Group Functions
PPT
computer notes - Data Structures - 22
PPT
computer notes - Data Structures - 36
DOC
Computer notes - Enhancements to the GROUP BY Clause
DOC
Computer notes - Manipulating Data
DOC
Computer notes - Writing Basic SQL SELECT Statements
DOC
Computer notes - Controlling User Access
DOC
Computer notes - Using SET Operator
PPT
computer notes - Data Structures - 29
PPT
computer notes - Data Structures - 38
PPT
computer notes - Data Structures - 25
computer notes - Data Structures - 30
Computer notes - Including Constraints
Computer notes - Date time Functions
Computer notes - Subqueries
Computer notes - Other Database Objects
computer notes - Data Structures - 4
Computer notes - Advanced Subqueries
Computer notes - Aggregating Data Using Group Functions
computer notes - Data Structures - 22
computer notes - Data Structures - 36
Computer notes - Enhancements to the GROUP BY Clause
Computer notes - Manipulating Data
Computer notes - Writing Basic SQL SELECT Statements
Computer notes - Controlling User Access
Computer notes - Using SET Operator
computer notes - Data Structures - 29
computer notes - Data Structures - 38
computer notes - Data Structures - 25

Recently uploaded (20)

PDF
Hip Hop Culture – More Than Just Music & Style
PPTX
Goal - its setting ,tracking and relevance
PPTX
Squares64 Quiz, A chessboard of questions, crafted with care by @mahi_anmol_ ...
DOCX
Elisabeth de Pot, the Witch of Flanders .
PPTX
AEN 302 - Brinjal, Bhendi, Tomato Pests - PPT 1 - Agri Junction.pptx.pptx
PDF
Download GTA 5 Free Full PC Game+Latest Version 2025
PDF
WKA? #29.5: "HELLO NURSE" TRANSCRIPT.pdf
PDF
mnbnyuynhncf ytdnbvdfghdfhghdhdfhdghdghdghghgfhfh
PDF
Download FL Studio Crack Latest version 2025
PPTX
G.A.M.E. O.N.! (General — Art — Mythology — Entertainment — Obscure Naata) [2...
DOCX
Talking Owls and Time Travel: Lessons in Curiosity
PDF
Lucky_MangA chapter 2. Story and Art by Enaji Studio
PDF
WKA #29: "FALLING FOR CUPID" TRANSCRIPT.pdf
PPTX
701301-Happy Birthday Slideshow Template.pptx
PPTX
Kulipari: Army of Frogs Movie - OVFX Story Internship 2023
PDF
Can You Imagine? Read along and let’s see!
DOC
UNG毕业证学历认证,阿莱恩特国际大学毕业证文凭证书
PDF
Module-3-Week005-to-Week006-PPT.pdf hahahgs
PPTX
Safety_Pharmacology_Tier2_Edibbbbbbbbbbbbbbbable.pptx
PPTX
GILGIT BALTISTAN HISTORY ,ADMINISTRATIVE , CONSTITUTUINAL STATUS , GEOGRAPMY ...
Hip Hop Culture – More Than Just Music & Style
Goal - its setting ,tracking and relevance
Squares64 Quiz, A chessboard of questions, crafted with care by @mahi_anmol_ ...
Elisabeth de Pot, the Witch of Flanders .
AEN 302 - Brinjal, Bhendi, Tomato Pests - PPT 1 - Agri Junction.pptx.pptx
Download GTA 5 Free Full PC Game+Latest Version 2025
WKA? #29.5: "HELLO NURSE" TRANSCRIPT.pdf
mnbnyuynhncf ytdnbvdfghdfhghdhdfhdghdghdghghgfhfh
Download FL Studio Crack Latest version 2025
G.A.M.E. O.N.! (General — Art — Mythology — Entertainment — Obscure Naata) [2...
Talking Owls and Time Travel: Lessons in Curiosity
Lucky_MangA chapter 2. Story and Art by Enaji Studio
WKA #29: "FALLING FOR CUPID" TRANSCRIPT.pdf
701301-Happy Birthday Slideshow Template.pptx
Kulipari: Army of Frogs Movie - OVFX Story Internship 2023
Can You Imagine? Read along and let’s see!
UNG毕业证学历认证,阿莱恩特国际大学毕业证文凭证书
Module-3-Week005-to-Week006-PPT.pdf hahahgs
Safety_Pharmacology_Tier2_Edibbbbbbbbbbbbbbbable.pptx
GILGIT BALTISTAN HISTORY ,ADMINISTRATIVE , CONSTITUTUINAL STATUS , GEOGRAPMY ...

computer notes - Data Structures - 31

  • 1. Class No.31 Data Structures http://ecomputernotes.com
  • 2. Timing with Optimization Theorem: A sequence of m union and find operations, n of which are find operations, can be performed on a disjoint-set forest with union by rank (weight or height) and path compression in worst case time proportional to ( m ( n ))  ( n )is the inverse Ackermann’s function which grows extremely slowly. For all practical puposes,  ( n )  4. Union-find is essentially proportional to m for a sequence of m operations, linear in m . http://ecomputernotes.com
  • 3. Image Segmentation Inclusion criteria for pixels use pixel intensity, threshold of intensity, threshold for difference in intensity of neighbors, texture (ie. a pattern of pixel intensities) http://ecomputernotes.com
  • 4. Image Segmentation 0 1 2 3 4 0 0 0 0 4 4 1 2 0 4 4 0 2 4 2 2 4 4 3 4 4 0 4 4 4 0 2 2 4 0 http://ecomputernotes.com
  • 5. Image Segmentation 0 1 2 3 4 0 0 0 0 4 4 1 2 0 4 4 0 2 4 2 2 4 4 3 4 4 0 4 4 4 0 2 2 4 0 0 1 2 3 4 0 0 0 0 1 1 1 0 0 1 1 0 2 1 0 0 1 1 3 1 1 0 1 1 4 0 0 0 1 0 Threshold=4 http://ecomputernotes.com
  • 6. Image Segmentation 0 1 2 3 4 0 0 0 0 4 4 1 2 0 4 4 0 2 4 2 2 4 4 3 4 4 0 4 4 4 0 2 2 4 0 0 1 2 3 4 0 0 0 0 1 1 1 1 0 1 1 0 2 1 1 1 1 1 3 1 1 0 1 1 4 0 1 1 1 0 Threshold=2 http://ecomputernotes.com
  • 8. Maze Generation A random maze generator can use union-find. Consider a 5x5 maze: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 http://ecomputernotes.com
  • 9. Maze Generator Initially, 25 cells, each isolated by walls from the others. This corresponds to an equivalence relation -- two cells are equivalent if they can be reached from each other (walls been removed so there is a path from one to the other). http://ecomputernotes.com
  • 10. Maze Generator To start, choose an entrance and an exit. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24   http://ecomputernotes.com
  • 11. Maze Generator Randomly remove walls until the entrance and exit cells are in the same set. Removing a wall is the same as doing a union operation. Do not remove a randomly chosen wall if the cells it separates are already in the same set. http://ecomputernotes.com
  • 12. MakeMaze MakeMaze(int size) { entrance = 0; exit = size-1; while (find(entrance) != find(exit)) { cell1 = randomly chosen cell cell2 = randomly chosen adjacent cell if (find(cell1) != find(cell2) { knock down wall between cells union(cell1, cell2) } } http://ecomputernotes.com
  • 13. Maze Generator Cell 11, right wall chosen randomly 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24   http://ecomputernotes.com
  • 14. Maze Generator Cell 11, right wall chosen randomly 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24   S_11 = { 11,12} http://ecomputernotes.com
  • 15. Maze Generator Cell 6, bottom wall chosen randomly 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24   S_11 = { 11,12} http://ecomputernotes.com
  • 16. Maze Generator Cell 6, bottom wall chosen randomly 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24   S_11 = { 11,12, 6} http://ecomputernotes.com
  • 17. Maze Generator Cell 8, top wall chosen randomly 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24   S_11 = { 11,12, 6} http://ecomputernotes.com
  • 18. Maze Generator Cell 8, top wall chosen randomly 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24   S_11 = { 11,12, 6} S_8 = { 8,3} http://ecomputernotes.com
  • 19. Maze Generator Cell 14, top wall chosen randomly 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24   S_11 = { 11,12, 6} S_8 = { 8,3} http://ecomputernotes.com
  • 20. Maze Generator Cell 14, top wall chosen randomly 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24   S_11 = { 11,12, 6} S_8 = { 8,3} S_14 = { 14,9} http://ecomputernotes.com
  • 21. Maze Generator Cell 0, bottom wall chosen randomly 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24   S_11 = { 11,12, 6} S_8 = { 8,3} S_14 = { 14,9} http://ecomputernotes.com
  • 22. Maze Generator Cell 0, bottom wall chosen randomly 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24   S_11 = { 11,12, 6} S_8 = { 8,3} S_14 = { 14,9} S_0 = { 0,5} http://ecomputernotes.com

Editor's Notes

  • #3: End of lecture 36
  • #4: Start lecture 37 here.
  • #23: End of lecture 37.